home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / portable / flushinp.c < prev    next >
C/C++ Source or Header  |  1993-06-20  |  2KB  |  71 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #undef    flushinp
  4.  
  5. #ifdef PDCDEBUG
  6. char *rcsid_flushinp = "$Header: C:\CURSES\portable\RCS\flushinp.c 2.1 1993/06/18 20:19:56 MH Rel MH $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   flushinp()    - discard type-ahead
  15.  
  16.   X/Open Description:
  17.      Throws away any type-ahead that has been typed by the user and
  18.      has not yet been read by the program.
  19.  
  20.   PDCurses Description:
  21.      If the PDCurses library is compiled under DOS with the FAST_VIDEO
  22.      define true, then we will poke the BIOS keyboard buffer head and
  23.      tail pointers, resetting the typeahead.
  24.  
  25.      If this is not true, then we will be unable to reliably flush
  26.      the typeahead.
  27.  
  28.   X/Open Return Value:
  29.      The flushinp() function returns OK on success and ERR on error.
  30.  
  31.   X/Open Errors:
  32.      No errors are defined for this function.
  33.  
  34.   Portability:
  35.      PDCurses    int flushinp( void );
  36.      X/Open Dec '88    int flushinp( void );
  37.      BSD Curses    int flushinp( void );
  38.      SYS V Curses    int flushinp( void );
  39.  
  40. **man-end**********************************************************************/
  41.  
  42. int    flushinp(void)
  43. {
  44. extern int    c_pindex;        /* putter index */
  45. extern int    c_gindex;        /* getter index */
  46. extern int    c_ungind;        /* wungetch() push index */
  47.  
  48. #ifdef PDCDEBUG
  49.     if (trace_on) PDC_debug("flushinp() - called\n");
  50. #endif
  51.  
  52. #if defined(DOS) && defined(FAST_VIDEO)
  53.     setdosmemword (0x41a, getdosmemword (0x41c)); /* Force the BIOS kbd buf       */
  54.                     /* head/tail pointers to be the */
  55.                     /* same...  Real nasty trick... */
  56. #endif
  57.  
  58. #ifdef OS2
  59.     KbdFlushBuffer(0);
  60. #endif
  61.  
  62. #ifdef UNIX
  63. /* INCOMPLETE */
  64. #endif
  65.  
  66.     c_gindex = 1;            /* set indices to kill buffer     */
  67.     c_pindex = 0;
  68.     c_ungind = 0;            /* clear c_ungch array         */
  69.     return( OK );
  70. }
  71.